package com.atguigu.e_objectstream;

import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

public class Student implements Serializable {
    @Serial
    private static final long serialVersionUID = -8220440394000331977L;//实现动作 : 做标记 , 只有被标记的类的对象才能被序列化操作!
    private String sid;
    private String name;
    private int age;
    private String gender;
    private String address; //在学生类中增加属性 [修改了学生类中的内容]

    public Student() {
    }

    public Student(String sid, String name, int age, String gender) {
        this.sid = sid;
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(sid, student.sid) && Objects.equals(name, student.name) && Objects.equals(gender, student.gender);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sid, name, age, gender);
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid='" + sid + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                '}' + " address : " + address;
    }
}
